#include "SceneManager.h"
#include "UIScene.h"

static SceneManager * g_pSharedInstance = NULL;

SceneManager::SceneManager()
{
	m_currSceneId = 0;
}

SceneManager::~SceneManager()
{

}

bool SceneManager::init()
{
	return true;
}

SceneManager * SceneManager::sharedSceneManager()
{
	if (g_pSharedInstance == NULL)
	{
		g_pSharedInstance = new SceneManager();
		if (g_pSharedInstance && g_pSharedInstance->init())
		{
			g_pSharedInstance->autorelease();
			return g_pSharedInstance;
		}
		else
		{
			delete g_pSharedInstance;
			g_pSharedInstance = NULL;
			return NULL;
		}
	}
	return g_pSharedInstance;
}

void SceneManager::purgeSceneManager()
{
	CC_SAFE_DELETE(g_pSharedInstance);
}

CCScene * SceneManager::currScene()
{
	return NULL;
}

void SceneManager::loadingScene(SceneID_T sceneId, s_32 heroPosX, s_32 heroPosY, CCObject * target, SEL_CallFuncO selector)
{
	if (m_currSceneId == sceneId) return;
	m_currSceneId = sceneId;
	CCScene * pScene = UIScene::scene();
	CCDirector::sharedDirector()->replaceScene(pScene);
	if (target && selector)
	{
		(target->*selector)(pScene);
	}
}